﻿using RabbitMQ.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RabbitMq.Send
{
    class Program
    {
        static void Main(string[] args)
        {
            var factory = new ConnectionFactory() { HostName = "localhost" };
            using (var connection = factory.CreateConnection())
            {
                using (var chanel = connection.CreateModel())
                {
                    chanel.QueueDeclare(queue: "task_queue", durable: true, exclusive: false, autoDelete: false, arguments: null);
                    Random random = new Random(9);
                    var properties = chanel.CreateBasicProperties();
                    properties.Persistent = true;
                    for (int i = 0; i < 10000; i++)
                    {
                        var message = Encoding.UTF8.GetBytes("Hello" + i.ToString() + "...");
                        chanel.BasicPublish(exchange: "", routingKey: "task_queue", basicProperties: properties, body: message);
                    }
                    Console.ReadKey();
                }
            }
        }
        private static string GetMessage(string message)
        {
            return ((message.Length > 0) ? string.Join(" ", message) : "Hello World!");
        }
    }
}
